home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 51741 / 51741.xpi / chrome / content / js / _main.js
Text File  |  2010-02-01  |  2KB  |  66 lines

  1. (function()
  2. {
  3.             var debugingThisFile = false;//sets debuging on/off for this JavaScript file
  4.         //add the listeners
  5.             this.addListener('browserLoad', function(){metaTitleDescriptionOnTop.metaTitleDescriptionOnTopInit()});
  6.             //listeningn the actual tab
  7.             this.addListener('onLocationChange', function (aDoc){metaTitleDescriptionOnTop.showMetaTitleAndDescription(aDoc)});
  8.  
  9.         //shutdown
  10.             this.addShutDown(function(){ metaTitleDescriptionOnTop.removeMenu();});
  11.  
  12.         this.metaTitleDescriptionOnTopInit = function()
  13.         {
  14.             this.dump('metaTitleDescriptionOnTopInit', debugingThisFile);
  15.             this.addMenu();
  16.         }
  17.         //adds the menuitem to the tab context menu
  18.         this.addMenu = function ()
  19.         {
  20.             this.dump('addMenu', debugingThisFile);
  21.             
  22.             this.tabContextMenu().appendChild(this.getElement('menuitem'));
  23.         };
  24.         //remove the menuitem from the tab context menu
  25.         this.removeMenu = function()
  26.         {
  27.             this.dump('removeMenu', debugingThisFile);
  28.             this.removeElement(this.getElement('menuitem'));
  29.         }
  30.         this.switch = function(item)
  31.         {
  32.             if(item.getAttribute('checked') == 'true')
  33.             {
  34.                 this.dump('switch:checked:true', debugingThisFile);
  35.                 this.initListeners();
  36.                 this.showMetaTitleAndDescription();
  37.             }
  38.             else
  39.             {
  40.                 this.dump('switch:checked:false', debugingThisFile);
  41.                 this.removeListeners();
  42.                 this.hideMetaTitleAndDescription();
  43.             }
  44.         }
  45.         this.showMetaTitleAndDescription = function (aDoc)
  46.         {
  47.             if(!aDoc)
  48.                 aDoc = this.documentGetFocused();
  49.             var title = this.documentGetTitle(aDoc);
  50.             var metaDescription = this.documentGetMetaDescription(aDoc);
  51.             
  52.             this.hideMetaTitleAndDescription();
  53.             
  54.             this.lastDescriptionBox = this.notifyTabs(this.getString('description')+' : '+metaDescription);
  55.             this.lastTitleBox = this.notifyTabs(this.getString('title')+' : '+title);
  56.         };
  57.         this.hideMetaTitleAndDescription = function (aDoc)
  58.         {
  59.             this.removeElement(this.lastTitleBox);
  60.             this.removeElement(this.lastDescriptionBox);
  61.         }
  62.  
  63.     return null;
  64.  
  65. }).apply(metaTitleDescriptionOnTop);
  66.